<template>
	<w-container class='page-bg flex flex-dir-col'>
		<w-navbar id='my-nav' :placeholder="true" title="开盒记录"></w-navbar>
		<view class="plr-16 ptb-12 flex flex-js-sb flex-ai-center" v-for="item in list" :key="item.id">
			<view class="">
				<view class="font-size-14 font-color-black">{{item.userss.nickname}}</view>
				<view class='mt-8 font-size-12 font-color-minor'>{{item.createtime|formatDate}}</view>
			</view>
			<view class="font-size-14">
				<text class="font-color-minor mr-4">抽中</text>
				<text class="font-color-black">{{item.collections.name}}</text>
			</view>
		</view>
		<w-loading :type="loading" emptyType="search"></w-loading>
	</w-container>
</template>

<script>
	import {getOpenRecord} from '@/api/box/index.js'
	export default {
		data() {
			return {
				id:null,
				loading:'none',
				search:{
					blind_box_id:null,
					page:1,
					list_rows:20
				},
				list:[]
			}
		},
		onLoad({id}) {
			this.search.blind_box_id=id;
			this.getRecord(this.search);
		},
		onReachBottom() {
			this.loadMore();
		},
		methods: {
			loadMore(){
				let search=this.$tools.copyObj(this.search)
				search.page++
				this.getRecord(search);
			},
			getRecord(search){
				if(this.loading=='loading') return ;
				this.loading='loading';
				getOpenRecord(search).then(res=>{
					this.loading='none';
					if(res.data.total==0){
						this.loading='empty'
					}
					if(res.data.data.length){
						res.data.data.map(v=>{
							this.$set(this.list,this.list.length,v)
						})
						this.search=search;
					}
					
				})
			}
		}
	}
</script>

<style>

</style>
